package com.example.test;

import com.dtflys.forest.http.ForestResponse;
import com.example.client.MyClient;
import lombok.SneakyThrows;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class test01 implements ApplicationRunner {

    @Resource
    MyClient myClient;

    @SneakyThrows
    @Override
    public void run(ApplicationArguments args) throws Exception {
        m03();
    }

    private void m03() throws Throwable {
        ForestResponse<String> response = myClient.helloWorld();
        System.out.println(response.getResult());
        if (response.getException()!=null){
            System.out.println(response.getRequestTime()+"==========="+response.getResponseTime());
            throw response.getException();
        }
    }

    private void m01() {
        String url="https://10.253.48.219:1080/bond/v1/quotations/orders/query";
        String authorization="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJib25kIiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sImV4cCI6MjUxODk5Mzg3Miwia3NEb21haW5Vc2VyIjp7InBhc3N3b3JkIjpudWxsLCJ1c2VybmFtZSI6ImJvbmQiLCJhdXRob3JpdGllcyI6W3siYXV0aG9yaXR5IjoiTk9STUFMIn1dLCJhY2NvdW50Tm9uRXhwaXJlZCI6dHJ1ZSwiYWNjb3VudE5vbkxvY2tlZCI6dHJ1ZSwiY3JlZGVudGlhbHNOb25FeHBpcmVkIjp0cnVlLCJlbmFibGVkIjp0cnVlLCJ1c2VySWQiOiIwMDRFR0dUTVE5MUdYIiwiZGlzcGxheU5hbWUiOiJib25kIiwiZW1wbG95ZWVObyI6IjEyMzQ1NiIsInByb2ZpbGVVcmwiOm51bGwsInVzZXJUeXBlIjoiMCIsImF0dHJpYnV0ZXMiOnt9LCJ0ZW5hbnRJZCI6bnVsbCwidGVuYW50QWRtaW5JZCI6bnVsbH0sImF1dGhvcml0aWVzIjpbIk5PUk1BTCJdLCJqdGkiOiI5MWZlNThiZS0zNTk4LTRjZjgtOGE0MC1mYjY1MjI1NTNkZjEiLCJjbGllbnRfaWQiOiJ0ZXN0and0Y2xpZW50aWQifQ.a8kpPrg2s0q2XBIEB7JMrUW_GsTqpPPpuFwRQC6-OmWMlXdV10buIrnyrVH8kVsTZDrV8_Cz2Gs5uTT530bemY_wz3GyYvJ9Q0Wcc7AdxWJ3hk6VlooPPmMROkcBjWmsvrAFdR64nTv-ab_TfQ3F-BbzgtMDdUlN4NQGQOzVT9REmoyctyG5oy0fxhwtFJzo3eI1I_TofsjDT6HEK20xBe7jCUBFw9XsimktvsEDXUY2AAQEq3k84sr40UQgZHfMTu3kh8rz3H4KfZNlPEFAjxKcei2Jjjb0mHYh3ZwO496TqGYp4N5y55cKn7Gco8DX6PzsA4kUBPIeFjfhLUIv3w";
        String jsonText="{\"data\":{\"securityId\":\"\",\"securityType\":[],\"settleType\":[],\"quotationFrq\":[],\"maturityDate\":[],\"status\":[],\"marketGroup\":\"1407153469684568065\",\"focusGroup\":\"\",\"quotationType\":[]},\"pageNo\":1,\"pageSize\":20}";
        ForestResponse<Object> response = myClient.quotations(url,authorization,jsonText);

        System.out.println(response);
    }
    private void m02() {
        String url="https://10.253.48.219:1080/bis/v1/holidays/settle/get";
        String authorization="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJib25kIiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sImV4cCI6MjUxODk5Mzg3Miwia3NEb21haW5Vc2VyIjp7InBhc3N3b3JkIjpudWxsLCJ1c2VybmFtZSI6ImJvbmQiLCJhdXRob3JpdGllcyI6W3siYXV0aG9yaXR5IjoiTk9STUFMIn1dLCJhY2NvdW50Tm9uRXhwaXJlZCI6dHJ1ZSwiYWNjb3VudE5vbkxvY2tlZCI6dHJ1ZSwiY3JlZGVudGlhbHNOb25FeHBpcmVkIjp0cnVlLCJlbmFibGVkIjp0cnVlLCJ1c2VySWQiOiIwMDRFR0dUTVE5MUdYIiwiZGlzcGxheU5hbWUiOiJib25kIiwiZW1wbG95ZWVObyI6IjEyMzQ1NiIsInByb2ZpbGVVcmwiOm51bGwsInVzZXJUeXBlIjoiMCIsImF0dHJpYnV0ZXMiOnt9LCJ0ZW5hbnRJZCI6bnVsbCwidGVuYW50QWRtaW5JZCI6bnVsbH0sImF1dGhvcml0aWVzIjpbIk5PUk1BTCJdLCJqdGkiOiI5MWZlNThiZS0zNTk4LTRjZjgtOGE0MC1mYjY1MjI1NTNkZjEiLCJjbGllbnRfaWQiOiJ0ZXN0and0Y2xpZW50aWQifQ.a8kpPrg2s0q2XBIEB7JMrUW_GsTqpPPpuFwRQC6-OmWMlXdV10buIrnyrVH8kVsTZDrV8_Cz2Gs5uTT530bemY_wz3GyYvJ9Q0Wcc7AdxWJ3hk6VlooPPmMROkcBjWmsvrAFdR64nTv-ab_TfQ3F-BbzgtMDdUlN4NQGQOzVT9REmoyctyG5oy0fxhwtFJzo3eI1I_TofsjDT6HEK20xBe7jCUBFw9XsimktvsEDXUY2AAQEq3k84sr40UQgZHfMTu3kh8rz3H4KfZNlPEFAjxKcei2Jjjb0mHYh3ZwO496TqGYp4N5y55cKn7Gco8DX6PzsA4kUBPIeFjfhLUIv3w";
        ForestResponse<Object> response = myClient.holidays(url,authorization,"1","4");

        System.out.println(response.getResult());
    }
}
